<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/webpage/include/taglib.jsp" %>
<html>
<head>
    <title>Title</title>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="decorator" content="ani"/>
    <%@ include file="/webpage/include/bootstraptable.jsp" %>
    <%@include file="/webpage/include/treeview.jsp" %>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>
</head>
<body>
<script>
    function callbackresult() {
        return "ab";
    }
</script>
<script>
    var page = {
        selectInit: function() {
            var res = {
                account_arr: [{
                    id: 1,
                    name: '苹果',
                    select: true
                },
                    {
                        id: 2,
                        name: '苹果2',
                        select: false
                    }
                ]
            }
            var str = "";
            //res.account_arr是你从接口接收到的那个数组
            for(var i = 0; i < res.account_arr.length; i++) {
                if(res.account_arr[i].select == true) {
                    str += '<option value="' + res.account_arr[i].id + '" selected="selected">' + res.account_arr[i].name + '</option>'
                } else {
                    str += '<option value="' + res.account_arr[i].id + '">' + res.account_arr[i].name + '</option>'
                }
            }
            $(".selectpicker").html(str);
            $('.selectpicker').selectpicker('refresh'); //动态刷新
        }
    }
    $(function() {
        page.selectInit()
        $('#btn').bind('click', function() {
            alert($('select').val())
        })
    })
</script>
<div class="wrapper wrapper-content">
    <div class="panel panel-primary">
        <div class="panel-body">

<%--            <sys:treeselect id="office" name="office.id" value="${leave1.office.id}"--%>
<%--                            labelName="office.name" labelValue="${leave1.office.name}"--%>
<%--                            title="部门" url="/sys/office/treeData?type=1" cssClass="form-control"--%>
<%--                            allowClear="true" notAllowSelectParent="true" checked="true"/>--%>
    <select id="select" name="select" class="selectpicker show-tick form-control" multiple data-live-search="true" data-actions-box="true">

        <option value="苹果">苹果</option>
        <option value="菠萝">菠萝</option>
    </select>
    <a id="btn" class="btn btn-success">获取数据</a>
        </div>
    </div>
</div>
</body>
</html>
